<form class="layui-form seller-form" action="">
    <div class="layui-form-item">
        <div class="layui-inline">
            <div class="layui-input-inline seller-inline-3" style="width:210px;">
                <input type="text" name="user_mobile" lay-verify="title" placeholder="绑定账号的手机号或用户名" autocomplete="off"
                    class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline seller-inline-2">
                <select name="type" lay-verify="">
                    <option value="">类型</option>
                    {volist name="params['user_wx']['type']" id="vo"}
                    <option value="{$key}">{$vo}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline seller-inline-2">
                <select name="gender" lay-verify="">
                    <option value="">性别</option>
                    <option value="1">男</option>
                    <option value="2">女</option>
                    <option value="0">其他</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline seller-inline-2">
                <input type="text" name="nickname" lay-verify="title" placeholder="昵称" autocomplete="off"
                    class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline seller-inline-3" >
                <input type="text" name="openid" lay-verify="title" placeholder="openid" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <button class="layui-btn layui-btn-sm" lay-submit lay-filter="user-search"><i
                    class="iconfont icon-chaxun"></i>筛选</button>
        </div>
    </div>
</form>

<div class="table-body">
    <table id="userTable" lay-filter="test"></table>
</div>

<script>
    var table, window_box;
    layui.use(['form', 'layedit', 'laydate', 'table'], function () {
        table = layui.table.render({
            elem: '#userTable',
            height: 'full-139',
            cellMinWidth: '80',
            page: 'true',
            limit: '20',
            url: "{:url('user/userwx')}?_ajax=1",
            id: 'userTable',
            cols: [[
                { field: 'id', title: 'ID', width:90, align: 'center' },
                {
                    field: 'option', title: '操作', templet: function (data) {
                        var html = '';
                        html += '<a  class="layui-btn layui-btn-xs option-del layui-btn-danger" data-id="' + data.id + '">删除</a>';
                        return html;
                    }, align: 'center', width: 80
                },
                { field: 'type_name', title: '类型',width:120,  align: 'center'},
                { field: 'user_name', title: '绑定账号',width:160,  align: 'center'},
                { field: 'mobile', title: '手机号码', width:140, align: 'center'},
                { field: 'openid', title: 'openId', width:200, align: 'center'},
                { field: 'nickname', title: '昵称',  align: 'center'},
                { field: 'gender', title: '性别',width:80,  align: 'center'},
                {
                    field: 'avatar', title: '头像',
                    templet: function (d) {
                        if (d.avatar) {
                            return '<a href="javascript:void(0);" onclick=viewImage("' + d.avatar + '")><image style="max-width:28px;max-height:28px;" src="' + d.avatar + '"/></a>';
                        } else {
                            return '<a href="javascript:void(0);" onclick=viewImage("<?php echo config('jshop.default_image'); ?>")><image style="max-width:30px;max-height:30px;" src="<?php echo config('jshop.default_image');?>"/></a>';
                        }
                    }, width: 80, align: 'center'
                },
                { field: 'country', title: '地区',  align: 'center',templet:function(d){
                    var html = "";
                    if(d.language){
                        html += (" " + d.language);
                    }
                        if(d.country){
                            html += (" " + d.country);
                        }
                        if(d.province){
                            html += (" " + d.province);
                        }
                        if(d.city){
                            html += (" " + d.city);
                        }



                    return html;
                    } },
                { field: 'ctime', title: '创建时间', align: 'center' },
                { field: 'utime', title: '更新时间', align: 'center' },
            ]]
        });
        //搜索
        layui.form.on('submit(user-search)', function (data) {
            layui.table.reload('userTable', {
                where: data.field
                , page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
        //角色删除
        $(document).on('click', '.option-del', function () {
            var id = $(this).attr('data-id');
            layer.confirm('您确定删除此记录吗？', {
                btn: ['确认', '取消'] //按钮
            }, function () {
                //去删除
                JsPost("{:url('user/userwxdel')}", { 'id': id }, function (res) {
                    if (res.status) {
                        layer.msg('删除成功');
                        table.reload();
                    } else {
                        layer.msg(res.msg);
                    }
                });
            }, function () {
                layer.close(1);
            });
        });
    });
</script>